package com.gjm.demo;


import com.gjm.demo.bean.Student;
import com.gjm.demo.component.ComponentTest;
import com.gjm.demo.configuration.ConfigurationTest;
import com.gjm.demo.controller.ControllerTest;
import com.gjm.demo.repository.RepositoryTest;
import com.gjm.demo.service.ServiceTest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RestController;


@SpringBootApplication
public class Springbootdemo2025219Application {

	public static void main(String[] args) {

//		ApplicationContext保存了spring中的对象，使用contest获取对象
		ApplicationContext context = SpringApplication.run(Springbootdemo2025219Application.class, args);
//
//		ControllerTest controllerBean1 = context.getBean(ControllerTest.class);//根据类型拿对象
//		controllerBean1.print();
//
//		ControllerTest controllerBean2 = (ControllerTest) context.getBean("Controller");//根据名字获取对象
//		controllerBean2.print();
//
//		ControllerTest controllerBean3 = context.getBean("controllerTest", ControllerTest.class);//根据名字和类型获取对象
//		controllerBean3.print();
//
//		System.out.println(controllerBean1);
//		System.out.println(controllerBean2);
//		System.out.println(controllerBean3);

//		ServiceTest serviceBean1 = (ServiceTest)context.getBean("serviceTest");
//		serviceBean1.print();
//
//		ServiceTest serviceBean2 = context.getBean(ServiceTest.class);
//		serviceBean2.print();
//
//		ServiceTest serviceBean3 = context.getBean("serviceTest", ServiceTest.class);
//		serviceBean3.print();

//		RepositoryTest repositoryBean1 = (RepositoryTest) context.getBean("repositoryTest");
//		repositoryBean1.print();
//
//		RepositoryTest repositoryBean2 = context.getBean(RepositoryTest.class);
//		repositoryBean2.print();
//
//		RepositoryTest repositoryBean3 = context.getBean("repositoryTest", RepositoryTest.class);
//		repositoryBean3.print();

//		Student studentBean1 = (Student)context.getBean("getStudent1");
//		System.out.println(studentBean1.toString());

//		Student studentBean2 = (Student)context.getBean("getStudent2");
//		System.out.println(studentBean2.toString());
//
//		Student studentBean3 = (Student)context.getBean("student1");
//		System.out.println(studentBean3.toString());

//		Student studentBean4 = (Student)context.getBean("getStudent3");
//		System.out.println(studentBean4.toString());

//		ComponentTest component = context.getBean(ComponentTest.class);
//		component.print();

		ConfigurationTest configuration = context.getBean(ConfigurationTest.class);
		configuration.print();

	}

}
